/**
 * Created by guangqiang on 2017/9/14.
 */
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { createIconSet } from 'react-native-vector-icons'
import json from '../../utils/iconfont/iconfont.json'

const OIcon = createIconSet(json, 'iconfont', 'iconfont.ttf')

const Icon = ({ name, size = 20, color = 'black', style }) => {
    if (!OIcon) throw new Error('没有找到匹配的font库，请review代码！')
    return (
        <OIcon color={color}
            name={name}
            size={size}
            style={style}
        />
    )
}

Icon.propTypes = {
    name: PropTypes.string.isRequired,
    size: PropTypes.number,
    color: PropTypes.string
}

export default Icon